/************************************************************************************************
 * test examples of 100 interesting program in C
 * test 066.c
 * division re-built & test
 ***********************************************************************************************/

#include <stdio.h>

/*
 * the most import way to re-built is to construct as many as possible restrict, then exhausting
 */

int main()
{
	int i = 0;
	for (i = 100; i < 1000; i += 100)
	{
		int product1 = i + 77;
		int j = 0;
		for (j = 1; j < 10; j++)
		{
			if (product1 % j == 0)
			{
				int divisor = product1/j; 
				if (divisor < 100 && ((divisor*7)/10)%10 == 7)
				{
					printf("%d, %d, %d\n", product1, divisor, divisor*7);
					// divisor is decided, so are first 2 digits of quotient (j & 7)
					// only thing left is exhausting the third digit 
				}
			}
		}
	}

	// divisor*8 has 3 digits, there is 4 digits in product 1 & 3, so quotient must be 989
	for (i = 100; i < 999; i++)
	{
		if (i*8 > 999) break;
		if (i*9 < 1000) continue;
		if (i*989/100 - i*9 < 100) // first remainder is less than 100 (2 digit)
			printf("%d\n", i);
	}
}

